package StreamOf;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author zc
 * @version 1.0
 * @date 2021/9/24 14:18
 * 【排序】
 * sorted()：自然排序，流中元素需实现Comparable接口
 */
public class Test9 {
    String[] ss = new String[3];
    public static void main(String[] args) {
        String[] sss = {"aa","ff","dd"};
        for (int i = 0; i < sss.length; i++) {
            String sss1 = sss[i];
            System.out.println(sss1);
        }

        System.out.println("【Arrays.asList】之后：");
        List<String> list = Arrays.asList(sss);
        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.print(s+" ");
        }

        //sorted()：自然排序，流中元素需实现Comparable接口
        System.out.println("\n排序之后：");
        list.stream().sorted().forEach(e-> System.out.print(e+" "));

    }
}
